package at.ac.thornwishstalon.ocrapp.main.fragments;

import android.app.Activity;
import android.app.FragmentTransaction;
import android.util.Log;

public class OCRAPPDialogHandler{		
	private final String TAG= "ocrapp_progress_dialog";
	private OcrappDialogFragment fragment;
	private Activity act;
	private static OCRAPPDialogHandler instance=null;
	
	public static OCRAPPDialogHandler getInstance(){
		if(instance==null)
			instance= new OCRAPPDialogHandler();
		return instance;
	}
	
	public void setActivity(Activity a){
		this.act=a;
	}
	
	public void showDialog(){
		fragment=  OcrappDialogFragment.newInstance();
		fragment.setActivity(act);
		
		Log.d(TAG,""+fragment.getShowsDialog());
		//FragmentTransaction ft= act.getFragmentManager().beginTransaction();
		fragment.show(act.getFragmentManager(), TAG);
		
		
	}
	public void dismissDialog(){
		fragment= (OcrappDialogFragment) act.getFragmentManager().findFragmentByTag(TAG);
		if(fragment!=null){
			//FragmentTransaction ft= ImageFragment.this.getFragmentManager().beginTransaction();
			//ft.remove(fragment);
			//ft.commit();
			fragment.getDialog().dismiss();
		}
	}
}
